import logging
import wsgiref.handlers
from google.appengine.ext import db
from google.appengine.ext import webapp


class Update(webapp.RequestHandler):
  '''Handles  /update request.'''
  def post(self):
    data = self.request.get("data")
    count = 0
    for hash in data.split(','):
      if Digest.gql("WHERE hash = :1", hash).get() is None:
        digest = Digest(hash=hash)
        digest.put()
        count += 1

    logging.info("Added %d digests." % count)

